
<%@ page import="com.gasstation.InventoryPremium; java.text.DecimalFormat" %>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
        <meta name="layout" content="main" />
        <g:set var="entityName" value="${message(code: 'inventoryPremium.label', default: 'InventoryPremium')}" />
        <title><g:message code="default.list.label" args="[entityName]" /></title>
    </head>
    <body>
        <div class="nav">
            <span class="menuButton"><a class="home" href="${createLink(uri: '/')}"><g:message code="default.home.label"/></a></span>
        </div>
        <div class="body">
            <h1><g:message code="default.list.label" args="[entityName]" /></h1>
            <g:form action="listAsPerMonth">
            <% Date date = (monthYear==null)?new Date():monthYear %>
            	<g:datePicker name="monthYear" value="${date}" precision="month"/> <g:submitButton name="showList" value="Go"/>
            
            <g:if test="${flash.message}">
            <div class="message">${flash.message}</div>
            </g:if>
            <div class="list">
                <table>
                    <thead>
                        <tr>
                        	<g:sortableColumn property="transactionOn" title="Date" />
                            <g:sortableColumn property="premiumOpenGallons" title="Open" />
                            <g:sortableColumn property="premiumOpenInvCost" title="Inv. \$" />
                            <g:sortableColumn property="premiumPurchasedGallons" title="Recd" />
                            <g:sortableColumn property="premiumPurchasedCost" title="\$" />
                            <g:sortableColumn property="premiumSaleGallons" title="Sale" />
                            <g:sortableColumn property="premiumCost" title="Cost \$" />
                            <g:sortableColumn property="premiumCloseGallons" title="Close" />
                            <g:sortableColumn property="premiumActualGallons" title="Actual" />
                            <g:sortableColumn property="premiumVariance" title="Variance" />
                            <g:sortableColumn property="premiumAvgCost" title="Avg. Cost" />
                        
                        </tr>
                    </thead>
                    <tbody>
                    <%DecimalFormat df = new DecimalFormat("#.####"); %>
                    <g:each in="${inventoryPremiumInstanceList}" status="i" var="inventoryPremiumInstance">
                        <tr class="${(i % 2) == 0 ? 'odd' : 'even'}">
                        
                            <td><g:formatDate date="${inventoryPremiumInstance.transactionOn}" format="MM/dd/yyyy"/></td>
                            <td>${df.format(inventoryPremiumInstance.premiumOpenGallons)}</td>
                            <td>$${df.format(inventoryPremiumInstance.premiumOpenInvCost)}</td>
                            <td>${df.format(inventoryPremiumInstance.premiumPurchasedGallons)}</td>
                            <td>$${df.format(inventoryPremiumInstance.premiumPurchasedCost)}</td>
                            <td>${df.format(inventoryPremiumInstance.premiumSaleGallons)}</td>
                            <td>$${df.format(inventoryPremiumInstance.premiumCost)}</td>
                            <td>${df.format(inventoryPremiumInstance.premiumCloseGallons)}</td>
                            <td>${df.format(inventoryPremiumInstance.premiumActualGallons)}</td>
                            <td>${df.format(inventoryPremiumInstance.premiumVariance)}</td>
                            <td>${df.format(inventoryPremiumInstance.premiumAvgCost)}</td>
                        </tr>
                    </g:each>
                    </tbody>
                </table>
            </div>
            <div class="paginateButtons">
                <g:paginate total="${inventoryPremiumInstanceTotal}" />
            </div>
            </g:form>
        </div>
    </body>
</html>
